<template>
<div class="dynamic-wrap">
    <ul class="dynamic-list">
       <li v-for="item in list" @click="openDynamicDetail(item.id)">
         <img :src="item.cover_img_url">
         <div>
             <h3>{{item.title}}</h3>
             <div class="dynamic-content" v-html="filterHtml(item.content)"></div>
         </div>
       </li>
    </ul>
</div>
</template>

<script>
    import {DYNAMIC_LIST} from '../../api';
    export default {
        data(){
            return{
              list:[],
              begin:1,
              end:10,
              listContent:''
            }
        },
        methods:{
          openDynamicDetail(dynamicId){
             //location.href="/dynamic/detail?dynamic_id="+id;
             this.$router.go({
                name:'dynamic.detail',
                params:{
                  dynamicId
                }
             })
          },
          getList(){
            const {begin,end} = this;
            this.$http.get(DYNAMIC_LIST,{
              begin,
              end,
              activity_id:this.$route.params.activityId
            })
            .then(res =>{
                if(res.data.code ==0){
                  this.list = res.data.data;
                }else{
                  this.$toast.show(res.data.message);
                }
            })
          },
          filterHtml:function(html){
              	function frame(html){
                   	var wrap = document.createElement('div');
                  	wrap.innerHTML = html;
                  	return wrap;
                }
             	return frame(html).innerText;
          }
        },
        ready(){
            this.getList();
        },
        components:{

        }
    }
</script>
<style lang="sass">
  @import "../../sass/publicity.scss";
</style>
